/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package tests.domainModel;

import java.util.Date;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;

import domainModel.Member;
import domainModel.MemberInt;
import domainModel.Post;
import static org.junit.Assert.*;

/**
 *
 * @author iziko
 */
public class PostTest {

    Post instance;
    Member mem;

    public PostTest() {
    }

    @BeforeClass
    public static void setUpClass() throws Exception {
    }

    @AfterClass
    public static void tearDownClass() throws Exception {
    }

    @Before
    public void setUp() {
        mem = new Member(1,"iziko","iz@mail","izik","orgad");
        instance = new Post(mem,"civic","is great!") ;
    }

    @After
    public void tearDown() {
    }

    /**
     * Test of setCreator method, of class Post.
     */
    @Test
    public void testSetCreator() {
        System.out.println("setCreator");
        MemberInt creator =    new Member(2,"iziko2","iz@mail","izik","orgad");
        instance.setCreator(creator);
        assertEquals(creator,instance.getCreator());
    }

    /**
     * Test of getContent method, of class Post.
     */
    @Test
    public void testGetContent() {
        System.out.println("getContent");
        String expResult = "is great!";
        String result = instance.getContent();
        assertEquals(expResult, result);
    }

    /**
     * Test of getCreationTime method, of class Post.
     */
    @Test
    public void testGetCreationTime() {
        System.out.println("getCreationTime");
        Date expResult = new Date();
        Date result = instance.getCreationTime();
        assertEquals(expResult, result);
    }

    /**
     * Test of getEditingTime method, of class Post.
     */
    @Test
    public void testGetEditingTime() {
        System.out.println("getEditingTime");
        Date expResult = new Date();
        Date result = instance.getEditingTime();
        assertEquals(expResult, result);
    }

    /**
     * Test of getId method, of class Post.
     */
    @Test
    public void testGetId() {
        System.out.println("getId");
        int expResult = 4;
        int result = instance.getId();
        assertEquals(expResult, result);
    }

    /**
     * Test of getTitle method, of class Post.
     */
    @Test
    public void testGetTitle() {
        System.out.println("getTitle");
        String expResult = "civic";
        String result = instance.getTitle();
        assertEquals(expResult, result);
    }

    /**
     * Test of setCreationTime method, of class Post.
     */
    @Test
    public void testSetCreationTime() {
        System.out.println("setCreationTime");
        Date ctime = new Date();
        instance.setCreationTime(ctime);
        assertEquals(ctime,instance.getCreationTime());
    }

    /**
     * Test of setEditingTime method, of class Post.
     */
    @Test
    public void testSetEditingTime() {
        System.out.println("setEditingTime");
        Date etime = new Date();
        instance.setEditingTime(etime);
        assertEquals(etime,instance.getEditingTime());
    }

    /**
     * Test of setTitle method, of class Post.
     */
    @Test
    public void testSetTitle() {
        System.out.println("setTitle");
        String title = "honda";
        instance.setTitle(title);
        assertEquals(title,instance.getTitle());
    }

    /**
     * Test of setContent method, of class Post.
     */
    @Test
    public void testSetContent() {
        System.out.println("setContent");
        String content = "is fast";
        instance.setContent(content);
         assertEquals(content,instance.getContent());
    }

    /**
     * Test of getCreator method, of class Post.
     */
    @Test
    public void testGetCreator() {
        System.out.println("getCreator");
        MemberInt expResult = mem;
        MemberInt result = instance.getCreator();
        assertEquals(expResult, result);
    }

    /**
     * Test of editPost method, of class Post.
     */
    @Test
    public void testEditPost() {
        System.out.println("editPost");
        String newContent = "subaru";
        String newTitle = "old car";
        instance.editPost(newContent, newTitle);
         assertEquals(newContent,instance.getContent());
    }

    /**
     * Test of setId method, of class Post.
     */
    @Test
    public void testSetId() {
        System.out.println("setId");
        int id = 3;
        instance.setId(id);
         assertEquals(id,instance.getId());
    }


}